util/mkimage: Some fixes to PE binaries section size calculation
authorJavier Martinez Canillas <javierm@redhat.com>
Fri, 16 Apr 2021 19:37:23 +0000 (21:37 +0200)
committerFelix Zielcke <fzielcke@z-51.de>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commit1d13294c237294818af3cadf973c9653344010a9
treed9d8561a993eb6ab4fcfbe496484e7c980fcf88a
parent1b2ca1057fc574c4cc51f25bae1b8384007f15f6
util/mkimage: Some fixes to PE binaries section size calculation

Commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper)
added a helper function to setup PE sections, but it caused regressions
in some arches where the natural alignment lead to wrong section sizes.

This patch fixes a few things that were caused the section sizes to be
calculated wrongly. These fixes are:

 * Only align the virtual memory addresses but not the raw data offsets.
 * Use aligned sizes for virtual memory sizes but not for raw data sizes.
 * Always align the sizes to set the virtual memory sizes.

These seems to not cause problems for x64 and aa64 EFI platforms but was
a problem for ia64. Because the size of the ".data" and "mods" sections
were wrong and didn't have the correct content. Which lead to GRUB not
being able to load any built-in module.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Bug-Debian: https://bugs.debian.org/987103

Patch-Name: mkimage-fix-section-sizes.patch

Gbp-Pq: Name mkimage-fix-section-sizes.patch
util/mkimage.c